﻿using NoteSystem.Utils;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Xml.Linq;

namespace NoteSystem
{
    /// <summary>
    /// CheckAccountHandler 的摘要说明
    /// </summary>
    public class CheckAccountHandler : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            //接收传递的账号
            string name = context.Request["Account"];
            //去数据库验证
            //如果账号能用返回true 如果不能用返回false
            string sql = string.Format("select * from users where account='{0}' ", name);
            DataSet ds = DbHelper.Query(sql);
            if (ds.Tables[0].Rows.Count > 0)
            {
                context.Response.Write("false");//账号存在 不可用
            }
            else
            {
                context.Response.Write("true");//账号不存在 可用
            }
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}